home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Goodies / AutoGuest / SampleUse.c < prev   
Text File  |  1991-09-18  |  2KB  |  46 lines

  1. /*----------------------------------------------------------------------
  2.     
  3.     This function shows the recommended way that your application
  4.     should use the authentication patches
  5.     
  6.     Since these routines patch traps which change the behavior of
  7.     the OS, it is a good idea to avoid installing them whenever
  8.     possible.  Ideally, your application will only call the
  9.     function 'InitialAESend' when it knows that it must start a
  10.     new session (i.e., it has a new address that it has never
  11.     messaged to before); at other times, it should call AESend
  12.     directly.
  13.     
  14. ----------------------------------------------------------------------*/
  15. OSErr InitialAESend( AppleEvent* question, AppleEvent* reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutTicks, IdleProcPtr idleProc, EventFilterProcPtr filterProc )
  16. {
  17.     long        oldPPC;
  18.     long        oldNoInteraction;
  19.     Boolean        useNoInteractionPatch;
  20.     OSErr        theErr;
  21.     
  22.     /*
  23.     // Install the two AutoGuest patches.  Only put in
  24.     // the 'noInteractionPatch' if we really need it
  25.     */
  26.     useNoInteractionPatch = !InForeGround();
  27.     oldPPC = InstallPPCAutoGuest();
  28.     if( useNoInteractionPatch )
  29.         oldNoInteraction = InstallNoInteractionPatch();
  30.     
  31.     /*
  32.     // Now that we have installed the patch or patches,
  33.     // try the AESend
  34.     */
  35.     theErr = AESend( question, reply, sendMode, sendPriority, timeOutTicks, idleProc, filterProc );
  36.  
  37.     /*
  38.     // Deinstall any patch that we installed
  39.     */
  40.     if( useNoInteractionPatch )
  41.         DeinstallNoInteractionPatch(oldNoInteraction);
  42.     DeinstallPPCAutoGuest(oldPPC);
  43.     
  44.     return theErr;
  45. }
  46.